//加载动画
$(document).ready(function () {
    $.ajax({
        url: 'https://api.gumengya.com/Api/YiYan',
        type: 'post',
        dataType: 'json',
        async: false,
        data: {
            format: 'json',
        },
        beforeSend: function () {
            //请求中执行的代码
        },
        complete: function () {
            //请求完成执行的代码
        },
        error: function () {
            //请求成功失败执行的代码
        },
        success: function (res) {
            // 状态码 200 表示请求成功
            if (res.code == 200) {
                let div = `
            <div class="swiper mySwiper">
                <div class="swiper-wrapper">
                    <div class="swiper-slide"><img src="/image/carousel/sp.jpg" alt=""></div>
                    <div class="swiper-slide"><img src="/image/carousel/ys.jpg" alt=""></div>
                    <div class="swiper-slide"><img src="/image/carousel/tq.jpg" alt=""></div>
                    <div class="swiper-slide"><img src="/image/carousel/tp.jpg" alt=""></div>
                    <div class="swiper-slide"><img src="/image/carousel/lt.jpg" alt=""></div>
                </div>
                <div class="swiper-button-next"></div>
                <div class="swiper-button-prev"></div>
                <div class="swiper-pagination"></div>
            </div>
            <div class="explain">
                <p>本网站是从其他网页上提取数据，并进行整理、分析、归纳、总结，并重新编辑成网页提供给用户阅读。本网站不提供任何商业用途，仅供学习交流使用。</p>
                <p>提供API接口，方便第三方开发者调用，提高效率。有需要者可以移步到<b>帮助中心</b>了解详情。</p>
                <p>我们还提供了爬虫的聊天群,有什么问题可以在群里面交流.</p>
            </div>
            <div class="qrcode">
                <span class="iconfont icon-fenxiang"></span>
            </div>
            <div class="ShareQRCode">
                <h2>扫描二维码</h2>
                <img src="https://api.gumengya.com/Api/QrCode?text=http://124.221.19.137/public/HTML/index.html?id=NaN">
                <p>手机扫描后建议使用横屏进行访问</p>
            </div>
                `
                $('.title').text(res.data.text)
                $('section').html(div)
                $('.qrcode').click(function (e) {
                    e.preventDefault();
                    $('.ShareQRCode').animate({ 'width': '100%' }, { duration: 500 });
                });
                $('.ShareQRCode').click(function (e) {
                    e.preventDefault();
                    $('.ShareQRCode').animate({ 'width': '0' }, { duration: 500 });
                });
                var swiper = new Swiper(".mySwiper", {
                    spaceBetween: 30,
                    centeredSlides: true,
                    autoplay: {
                        delay: 2500,
                        disableOnInteraction: false,
                    },
                    pagination: {
                        el: ".swiper-pagination",
                        clickable: true,
                    },
                    navigation: {
                        nextEl: ".swiper-button-next",
                        prevEl: ".swiper-button-prev",
                    },
                });
            } else {
                $('.promptBox').text(res.data.text).stop().animate({ 'width': '300px', 'height': '40px' }, 500, function () {
                    $(this).animate({ width: '0', height: '0' }, 1000);
                });
            }
        }
    })
})
